﻿using Duende.IdentityServer.ResponseHandling;
using Duende.IdentityServer.Validation;
using SimpleSaas.Web.Common.redis;
using SimpleSaasAuth.Configuration;

namespace SimpleSaasAuth
{
    public static class IdentityServerBuilderExtensions
	{
		public static IIdentityServerBuilder AddSTStore(this IIdentityServerBuilder builder, Action<RedisStoreOption> storeOptionsAction = null)
		{
			var options = new RedisStoreOption();
			builder.Services.AddSingleton(options);
			storeOptionsAction?.Invoke(options);
			builder.Services.AddTransient<IIntrospectionRequestValidator, CustomIntrospectionRequestValidator>();
			builder.Services.AddSingleton<ITokenResponseGenerator, CustomTokenReponseGenerator>();
			return builder;
		}
	}
}